<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
<script>
    var hasOwn = Object.prototype.hasOwnProperty;
    function mix(receiver, obj){
        var args = [].slice.call(arguments), key, i = 1, deep, ride, value, valueType;

        if( typeof args[args.length-2] === "boolean" ){
            deep = args.pop();
            ride = args.pop();
        }else{
            ride = (typeof args[args.length-1] === "boolean")?args.pop():true;
            deep = false;
            if(args.length < 2){
                receiver = ( this !== global ) ? this : {};
                if( args.length === 0 ){
                    return receiver;
                }
            }
        }

        while( obj = args[ i++ ] ){
            for( key in obj ){
                if( hasOwn.call(obj, key) ){
                    if( ride || !(key in receiver) ){
                        value = obj[key];
                        valueType = type(value);
                        if( deep && ( valueType==="object")){
                            receiver[key]={};
                            mix(receiver[key], value, ride, deep);
                        }else if( deep && ( valueType==="array" )){
                            receiver[key]=[];
                            mix(receiver[key], value, ride, deep);
                        }else{
                            receiver[key] = obj[key];
                        }
                    }
                }
            }
        }
        return receiver;
    }
    function extend(destination,source){
        for(var property in source){
            destination[property] = source[property];
        }
        return destination;
    }

    function A(){
        this.pro = 'myPro';
    }
    A.prototype = {
        aa: 1,
        bb: 2,
        obj: {}
    };
    function bridge(){}
    bridge.prototype = A.prototype;
    function B(){}
    B.prototype = {
        b: 1
    };
    B.prototype = new bridge;
    var a = new A;
    var b = new B;
    console.log(b);

    function inherit(init,Parent,proto){
        function Son(){
            if(typeof argument != 'undefined'){
                Parent.apply(this,argument);
                init.apply(this,argunmet);
            }
            else{
                Parent.apply(this);
                init.apply(this);
            }
        }
        Son.prototype = Object.create(Parent.prototype,{});
        Son.prototype.toString = Parent.prototype.toString;
        Son.prototype.valueOf = Parent.prototype.valueOf;
        Son.prototype.constructor = Son;
        extend(Son.prototype,proto);
        extend(Son,parent);
        return Son;
    }

    function Afun(){
        this.A = 1;
    }
    Afun.prototype = {
        aa: 1
    };
    function Bfun(){
        this.B = 2;
    }
    Bfun.prototype = {
        bb: 2
    };
    var n = inherit(Afun,Bfun,Afun.prototype);
    n = new n;
    console.log(n);
    var Afun = new Afun;
    var Bfun = new Bfun;

    console.log(extend(Afun,Bfun));
</script>
</body>
</html>